﻿using System.Collections.Generic;
using static CoreLims.Models.CoreLims.Env;

namespace CoreLims.Models.CoreLims
{
    public partial class Common
    {
        public class UnitTypeCompare : IEqualityComparer<CommonUnit>
        {
            bool IEqualityComparer<CommonUnit>.Equals(CommonUnit x, CommonUnit y)
            {
                return x.Type == y.Type;
            }

            int IEqualityComparer<CommonUnit>.GetHashCode(CommonUnit obj)
            {
                if (string.IsNullOrEmpty(obj.Type))
                { return 0; }
                else
                { return obj.Type.Length; }
            }
        }

        public class SiteGroupSiteCompare : IEqualityComparer<CommonSiteGroup>
        {
            bool IEqualityComparer<CommonSiteGroup>.Equals(CommonSiteGroup x, CommonSiteGroup y)
            {
                return x.Site == y.Site;
            }

            int IEqualityComparer<CommonSiteGroup>.GetHashCode(CommonSiteGroup obj)
            {
                if (string.IsNullOrEmpty(obj.Site))
                { return 0; }
                else
                { return obj.Site.Length; }
            }
        }

        public class SupplierSupplierTypeCompare : IEqualityComparer<CommonSupplier>
        {
            bool IEqualityComparer<CommonSupplier>.Equals(CommonSupplier x, CommonSupplier y)
            {
                return x.SupplierType == y.SupplierType;
            }

            int IEqualityComparer<CommonSupplier>.GetHashCode(CommonSupplier obj)
            {
                if (string.IsNullOrEmpty(obj.SupplierType))
                { return 0; }
                else
                { return obj.SupplierType.Length; }
            }
        }

        public class AreaAndLocationTypeCompare : IEqualityComparer<AreaAndLocation>
        {
            bool IEqualityComparer<AreaAndLocation>.Equals(AreaAndLocation x, AreaAndLocation y)
            {
                return x.Type == y.Type;
            }

            int IEqualityComparer<AreaAndLocation>.GetHashCode(AreaAndLocation obj)
            {
                if (string.IsNullOrEmpty(obj.Type))
                { return 0; }
                else
                { return obj.Type.Length; }
            }
        }

        public class MonitoringTypeCompare : IEqualityComparer<Monitoring>
        {
            bool IEqualityComparer<Monitoring>.Equals(Monitoring x, Monitoring y)
            {
                return x.Type == y.Type;
            }

            int IEqualityComparer<Monitoring>.GetHashCode(Monitoring obj)
            {
                if (string.IsNullOrEmpty(obj.Type))
                { return 0; }
                else
                { return obj.Type.Length; }
            }
        }

    }
}
